1
|
|
|
import { Link } from "gatsby" |
2
|
|
|
import { PropTypes } from "prop-types" |
3
|
|
|
import React, { Component } from "react" |
4
|
|
|
|
5
|
|
|
import { PlayerMinimal } from "./objects/player" |
6
|
|
|
import "./player--featured.scss" |
7
|
|
|
|
8
|
|
|
class PlayerFeatured extends Component { |
9
|
|
|
renderPlayerHeader = () => ( |
10
|
|
|
<header className={`player--featured__header`}> |
11
|
|
|
<div className={`bg-green-mask--horizontal`}> |
12
|
|
|
<div |
13
|
|
|
className={`player--featured__bg-avatar`} |
14
|
|
|
style={{ backgroundImage: `url(${this.props.player.imageSrc})` }} |
15
|
|
|
/> |
16
|
|
|
<div className={`bg-white-end`} /> |
17
|
|
|
</div> |
18
|
|
|
</header> |
19
|
|
|
) |
20
|
|
|
renderPlayerStats = () => ( |
21
|
|
|
<aside className={`player--featured__statistics`}> |
22
|
|
|
{this.renderGamesPlayed(this.props.player.gamesPlayed)} |
23
|
|
|
|
24
|
|
|
{this.props.player.position === `k` && this.renderCleansheets(this.props.player.cleanSheets)} |
25
|
|
|
|
26
|
|
|
{this.props.player.position !== `k` && this.renderGoals(this.props.player.goalsScored)} |
27
|
|
|
|
28
|
|
|
{this.renderCards(this.props.player.cardsYellow, `yellow`)} |
29
|
|
|
{this.renderCards(this.props.player.cardsRed, `red`)} |
30
|
|
|
</aside> |
31
|
|
|
) |
32
|
|
|
renderPlayerLink = () => ( |
33
|
|
|
<footer className={`player--featured__footer`}> |
34
|
|
|
<Link to={this.props.player.link} className="rich-link"> |
35
|
|
|
Meer over {this.props.player.nameFirst} » |
36
|
|
|
</Link> |
37
|
|
|
</footer> |
38
|
|
|
) |
39
|
|
|
renderPlayerName = () => ( |
40
|
|
|
<div className={`player--featured__name__wrapper`}> |
41
|
|
|
<h1 className={`player--featured__name`}> |
42
|
|
|
<span className={`player--featured__name-first`}>{this.props.player.nameFirst || `John`}</span> |
43
|
|
|
<span className={`player--featured__name-last`}>{this.props.player.nameLast || `Doe`}</span> |
44
|
|
|
</h1> |
45
|
|
|
<div className={`player--featured__bg-shirt-number`} aria-hidden="true"> |
46
|
|
|
{this.props.player.shirtNr || `0`} |
47
|
|
|
</div> |
48
|
|
|
</div> |
49
|
|
|
) |
50
|
|
|
renderGamesPlayed = (gamesPlayed) => ( |
51
|
|
|
<section className={`player--featured__statistics-item`}> |
52
|
|
|
<div className={`player--featured__statistics-item__number`}>{gamesPlayed || `0`}</div> |
53
|
|
|
<div className={`player--featured__statistics-item__label`}>Wedstrijden</div> |
54
|
|
|
</section> |
55
|
|
|
) |
56
|
|
|
renderCleansheets = (cleanSheets) => ( |
57
|
|
|
<section className={`player--featured__statistics-item`}> |
58
|
|
|
<div className={`player--featured__statistics-item__number`}>{cleanSheets || `0`}</div> |
59
|
|
|
<div className={`player--featured__statistics-item__label`}>Cleansheets</div> |
60
|
|
|
</section> |
61
|
|
|
) |
62
|
|
|
renderGoals = (goalsScored) => ( |
63
|
|
|
<section className={`player--featured__statistics-item`}> |
64
|
|
|
<div className={`player--featured__statistics-item__number`}>{goalsScored || `0`}</div> |
65
|
|
|
<div className={`player--featured__statistics-item__label`}>Doelpunten</div> |
66
|
|
|
</section> |
67
|
|
|
) |
68
|
|
|
|
69
|
|
|
renderCards = (cards, color) => ( |
70
|
|
|
<section className={`player--featured__statistics-item player--featured__statistics-item--cards`}> |
71
|
|
|
<div className={`player--featured__statistics-item__number`}>{cards || `0`}</div> |
72
|
|
|
<div className={`player--featured__statistics-item__label`}> |
73
|
|
|
<span className={`stats__card stats__card--${color}`}></span> |
74
|
|
|
</div> |
75
|
|
|
</section> |
76
|
|
|
) |
77
|
|
|
|
78
|
|
|
render() { |
79
|
|
|
return ( |
80
|
|
|
<article className={`player--featured`}> |
81
|
|
|
{this.renderPlayerHeader()} |
82
|
|
|
<section className={`player--featured__content`}> |
83
|
|
|
{this.renderPlayerName()} |
84
|
|
|
{this.renderPlayerStats()} |
85
|
|
|
{this.props.player.link && this.renderPlayerLink()} |
86
|
|
|
</section> |
87
|
|
|
</article> |
88
|
|
|
) |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
PlayerFeatured.propTypes = { |
93
|
|
|
player: PropTypes.instanceOf(PlayerMinimal).isRequired, |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
export default PlayerFeatured |
97
|
|
|
|